<%@ page contentType="text/html; charset=utf-8"%>
<%@ page import="java.math.BigDecimal"%>
<%@ page import="lib.db.admin.*"%>
<jsp:useBean id="bdAdminDAO" class="lib.db.admin.AdminDAO" scope="session"/>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK href="../include/default.css" type="text/css" rel="stylesheet">
<SCRIPT src="../include/default.js" type="text/javascript"></SCRIPT>
<title>ADMIN:EDIT:RESP</title>
</head>

<body>
<%@ include file="../include/header.jsp" %>
<br>

<%
    request.setCharacterEncoding("UTF-8");
    String sAction    = request.getParameter("action");
    String sUsername  = request.getParameter("txtUsername");
    String sPassword1 = request.getParameter("txtPassword1");
    String sPassword2 = request.getParameter("txtPassword2");
    String sAdminId   = request.getParameter("id");

    if (sAdminId == null || sAction  == null  || !"UPDATEPASS".equals(sAction)) {
    	return;
    }

    String inform = "";
    boolean success = false;
    if (sPassword1 == null || "".equals(sPassword1) ||
        sPassword2 == null || "".equals(sPassword2)) {
        inform = "Sorry, both passwords must be set.";
    } else if (!sPassword1.equals(sPassword2)) {
    	inform = "Sorry, passwords do not match.";
    } else {
    	success = bdAdminDAO.updatePassword(new BigDecimal(sAdminId), sPassword1, false);
        if (success) {
            inform = "YES, change password successfully!";
        }
    }

    String sRef = "/web/webadmin/index.jsp";
    String sHeader = "OK";
    if (!success) {
        sRef = "javascript:history.go(-1);";
        sHeader = "ERROR";
    }
%>

<%@ include file="../include/msg_box.jsp" %>

</body>
</html>
